package com.jeesite.modules.app.sys.area;

import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.jeesite.common.entity.Extend;
import com.jeesite.common.lang.StringUtils;
import com.jeesite.common.mapper.JsonMapper;
import com.jeesite.modules.conf.AppController;
import com.jeesite.modules.conf.MessageCode;
import com.jeesite.modules.sys.entity.Area;
import com.jeesite.modules.sys.entity.Office;
import com.jeesite.modules.sys.service.AreaService;

@Controller
@RequestMapping(value = "/app/sys/area/")
public class AppAreaController {
	@Autowired
	private AreaService areaService;
	@RequestMapping(value = "listData")
	public void listData(Area entity,HttpServletRequest request,HttpServletResponse response){
		String parentCode = entity.getParentCode();
		if(StringUtils.isBlank(parentCode)){
			AppController.renderErrorString(response, MessageCode.PARAMETER_IS_NEED,"节点信息");
			return;
		}
		List<Area> findList = areaService.findList(entity);		
		JSONArray jsonArr=JSONObject.parseArray(JsonMapper.toJson(findList));
		AppController.renderSuccessObject(response, jsonArr, MessageCode.SUCCESS_ACK);
	}
}
